package com.dengdai.applibrary.view.custom;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * @说明 ViewPager中嵌套ViewPager时的事件拦截处理
 * @作者 LY
 * @时间 15/12/23 14:52
 * @版权 Copyright(c) 2015 LY-版权所有
 */
public class CustomTabViewPager extends ViewPager {
    private boolean isTouch;

    public CustomTabViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * 触摸广告的时候，不拦截事件
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        if (isTouch) {
            return false;
        }
        return super.onInterceptTouchEvent(arg0);
    }

    public void setTouch(boolean isTouch) {
        this.isTouch = isTouch;
    }
}
